<%@ page isELIgnored="false" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html:html>
<head>
<title>
    <bean:message key="login.title"/>
</title>
<link rel="stylesheet" type="text/css" href="css/default.css" />
</head>

<script type="text/JavaScript">
	function incluir() {
		document.forms[0].action="categoriaDespesa.do?action=salvarCategoria";
		document.forms[0].submit();
	}
	
	function removerCategoria(cod) {
		document.forms[0].codCategoriaDespesa.value = cod;
		document.forms[0].action="categoriaDespesa.do?action=removerCategoria";
		document.forms[0].submit();
	}
	
	function pesquisar(){
		document.forms[0].action="categoriaDespesa.do?action=pesquisarCategoria";
		document.forms[0].submit();
	}
	
	function voltar() {
		document.forms[0].action="home.do";
		document.forms[0].submit();
	}
	
</script>
<body>
<jsp:include page="../menu.html"></jsp:include>
<div id="conteudo">
	<div align="center">
	<h1>Categorias</h1>
	<%=request.getAttribute("message") == null ? "" : request.getAttribute("message")%>
    <div id="conteudo_corpo">    
    <html:form action="/categoriaDespesa.do?action=pesquisarCategoria">
		<table class="form_tabela">
			<tr>
				<td class="form_label">Categoria</td>
				<td>
					<html:text size="30" property="descricao" styleId="descricao" onkeyup="javascript:DigitaLetra()" />
					<html:hidden property="codCategoriaDespesa" styleId="codCategoriaDespesa"/>
				</td>
			</tr>
		</table>
		<hr>
		<div align="center">
			<input type="button" value="Incluir" onclick="javascript:incluir();"/>
			<input type="button" value="Voltar" onclick="javascript:voltar();"/>
		</div>
    </html:form>
    </div>
  <c:if test="${!empty requestScope.listaCategorias}">
  <div id="conteudo_corpo" style="overflow: auto; width: 300px; height: 300px" align="center">
  <br>
  	<table border="1px">
  		<thead>
  			<tr>
  				<th scope="col" width="10%" align="center">Codigo</th>
  				<th scope="col" width="40%" align="center">Descricao</th>
  			</tr>
  		</thead>
	  <c:forEach items="${listaCategorias}" var="categoria">
	  	<tr>
	  		<td width="10%" align="center">${categoria.codCategoriaDespesa}</td>
	  		<td width="40%" align="center">${categoria.descricao}</td>
	  	</tr>
	  </c:forEach>
	</table>
  <br>
  </div>
 </c:if>
  </div>
</div>
</body>
</html:html>

